/*
 * $Id: sed.h,v 1.1 2006-04-23 16:05:59 bacon Exp $
 */

#ifndef _XP_UTL_SED_H_
#define _XP_UTL_SED_H_

#include <xp/types.h>
#include <xp/macros.h>

typedef struct xp_sed_t xp_sed_t;

typedef xp_ssize_t (*xp_sed_io_t) (
	int cmd, void* arg, xp_char_t* data, xp_size_t count);

enum 
{
	XP_SED_INPUT_OPEN   = 0,
	XP_SED_INPUT_CLOSE  = 1,
	XP_SED_INPUT_NEXT   = 2,
	XP_SED_INPUT_DATA   = 3,

	XP_SED_OUTPUT_OPEN  = 4,
	XP_SED_OUTPUT_CLOSE = 5,
	XP_SED_OUTPUT_NEXT  = 6,
	XP_SED_OUTPUT_DATA  = 7
};

enum
{
	XP_SED_ENOERR,
	XP_SED_ENOMEM

	XP_SED_ENOIO,
	XP_SED_EINOPEN,
	XP_SED_EINCLOSE,
	XP_SED_EOUTOPEN,
	XP_SED_EOUTCLOSE
};

#ifdef __cplusplus
extern "C" {
#endif

xp_sed_t* xp_sed_open (void);
void xp_sed_close (xp_sed_t* sed);
int xp_sed_run (xp_sed_t* sed, const xp_char_t* cmds[], xp_size_t ncmds);

#ifdef __cplusplus
}
#endif

#endif
